package com.wh.Server.Impl;

import com.wh.Mapper.WHouseMapper;
import com.wh.Server.WHouseService;
import com.wh.entity.WHouse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @Description WHouseServiceImpl
 * @Author zhq
 * @Date 2024-11-06
 */
@Service
public class WHouseServiceImpl implements WHouseService {

    @Autowired
    private WHouseMapper wHouseMapper;

    @Override
    public List<WHouse> listAll(WHouse wHouse){

        return wHouseMapper.list(wHouse);
    }

    @Override
    public List<WHouse> remain(Integer restock) {
        List<WHouse> wHouseList = wHouseMapper.remain(restock);

        Collections.sort(wHouseList, new Comparator<WHouse>() {
            @Override
            public int compare(WHouse o1, WHouse o2) {
                return o2.getStock() - o1.getStock();
            }
        });
        for(WHouse wHouse : wHouseList){


        }
        return null;
    }
}
